#ifndef _SERVER_H_
#define _SERVER_H_

#include <vector>
#include "socket.h"
class Module;

class Server
{
public:
  Server();
  ~Server();

  void Start();
  void Stop();
  void AddModule(Module* module);
  void AddSocket(int port, Module* module, bool ssl = false);

  std::string GetAddress() const;

protected:
  friend class Module;

  static void MainThreadDispatcher(void* server);
  void MainThread();
  std::string GetHeader();

  bool stopRequest;
  std::vector<Socket*> sockets;
  std::vector<Module*> modules;
  std::string header;
  std::string host;
  mutable std::string ipaddress;
};


#endif//_SERVER_H_

